package com.demo.chapter5stream2;

import com.demo.domain.Dish;

public class Find {

	public static void demo(){
		//返回当前流中的任意元素
		Dish.menu.stream().filter(Dish::isVegetarian).findAny()
			//ifPresent：如果结果有值就打印出来，否则不做操作
			.ifPresent(d -> System.out.println(d.getName()));
	}

	public static void demo2(){
		//返回当前流中的第一个元素
		Dish.menu.stream().filter(Dish::isVegetarian).findFirst()
			.ifPresent(d -> System.out.println(d.getName()));
	}

}
